package com.zbl.zblproject.erp.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.google.common.base.Joiner;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author youlanqiang
 * @version 1.0
 * @date 2018/10/10
 * 仓库实体类
 */
@TableName("zbl_erp_warehouse")
public class ErpWarehouse {

    @TableId(type = IdType.AUTO)
    private int id;

    /**
     * 仓库名称
     */
    @NotBlank(message = "仓库名不能为空")
    @NotNull(message = "仓库名不能为空")
    private String whName;

    /**
     * 货架编号
     */
    @NotBlank(message = "货架名不能为空")
    @NotNull(message = "货架名不能为空")
    private String shelvesId;

    /**
     * 货位
     */
    @NotBlank(message = "货位名不能为空")
    @NotNull(message = "货位名不能为空")
    private String goodsAllocation;

    /**
     * 是否启用
     */
    private int enabling;

    @TableField(exist = false)
    private int stock;

    @TableField(exist = false)
    private List<ErpWarehouseItem> items;


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getWhName() {
        return whName;
    }

    public void setWhName(String whName) {
        this.whName = whName;
    }

    public String getShelvesId() {
        return shelvesId;
    }

    public void setShelvesId(String shelvesId) {
        this.shelvesId = shelvesId;
    }

    public String getGoodsAllocation() {
        return goodsAllocation;
    }

    public void setGoodsAllocation(String goodsAllocation) {
        this.goodsAllocation = goodsAllocation;
    }

    public int getEnabling() {
        return enabling;
    }

    public void setEnabling(int enabling) {
        this.enabling = enabling;
    }

    public String getWarehouseName(){
        return Joiner.on("-").skipNulls().join(whName, shelvesId, goodsAllocation);
    }

    public List<ErpWarehouseItem> getItems() {
        return items;
    }

    public void setItems(List<ErpWarehouseItem> items) {
        this.items = items;
    }


    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    @Override
    public String toString() {
        return "ErpWarehouse{" +
                "id=" + id +
                ", whName='" + whName + '\'' +
                ", shelvesId='" + shelvesId + '\'' +
                ", goodsAllocation='" + goodsAllocation + '\'' +
                ", enabling=" + enabling +
                '}';
    }
}
